import QtQuick 1.1
import com.nokia.meego 1.0
import QuickGestures 1.0
import "HarmattanUIConstants.js" as Constants

PageStackWindow {
    id: root
    showStatusBar: true
    showToolBar: true

    initialPage: GestureListPage {
        id: gestureListPage
    }

    Connections {
        target: engine
        onReadyToQuit: Qt.quit();
    }

    Connections {
        target: storageThread

        onStateChanged: {
            if (state == StorageThread.Idle) {
                console.debug("StorageThread.state: Idle");
                progressLabel.hide();
                helper.clearModifiedGestures();
                gestureListPage.setSaved();
            }
            else if (state == StorageThread.Loading) {
                console.debug("StorageThread.state: Loading");
                progressLabel.value = 0.0;
                progressLabel.text = "Loading...";
                progressLabel.show();
            }
            else if (state == StorageThread.Saving) {
                console.debug("StorageThread.state: Saving");
                progressLabel.value = 0.0;
                progressLabel.text = "Saving...";
                progressLabel.show();
            }
        }

        onProgress: {
            console.debug("storageThread.onProgress():", percentsComplete / 100);
            progressLabel.value = percentsComplete / 100;
        }
    }

    ProgressLabel {
        id: progressLabel
        width: parent.width
        anchors.top: parent.top
        anchors.topMargin: Constants.DEFAULT_MARGIN * 2
        opacity: 0
        height: 0
        z: 2
    }

    Component.onCompleted: {
        theme.inverted = true;
    }
}

// End of file.
